<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="txt"><input type="button" id="btn">
<script>
    var url = 'http://www.w3school.com.cn/jsref/jsref_obj_global.asp?a=b&c=d你好';
    var s = encodeURIComponent(url);    //使用函数，并传入参数
    document.write(s);
    console.log(s);
    s = decodeURIComponent(s);  //使用函数，并传入参数
    console.log(s);

    //eval
    eval('alert("你好")');
    var s = "var a = 10;"
    eval(s);//功能很强大，但是尽量不要执行用户输入的内容
    var btn = document.getElementById('btn');
    var txt = document.getElementById('txt');
    btn.onclick = function(){
        var s = txt.value;
        eval(s);
    }

</script>
</body>
</html>